<html>
<head>
	<meta charset="UTF-8">
	<title>axios-请求方式</title>
	<script type="text/javascript" src="./axios.js"></script>
</head>
<body>

<script type="text/javascript">
//get 请求-1
axios({
	url: '/user/queryUserList.do',
	method: 'get',
	params: {
		id: '11',
		name: '22',
	}
}).then((res) => {
	console.log(res);
}).catch(function (err) {
    console.log(err);
});
//get 请求-2
axios.get('/user/queryUserList.do', {
	params: { 
		id: 'aa',
		name: 'bb'
	}
}).then(function (res) {
    console.log(res);
}).catch(function (err) {
    console.log(err);
});
</script>
<script type="text/javascript">
//post 请求-application/x-www-form-urlencoded（表单方式）
var formData = new FormData();
formData.append('param1', 'value1');
formData.append('param2', 'value2');
axios.post("/user/test1",formData).then((res) => {
	return res;
}).catch((err) => {
	return err;
});
//post 请求-application/json（JSON方式）
const params = {
	'param1': 'value1',
	'param2': 'value2',
};
axios.post('/user/test2', params);
</script>
</body>
</html>